package org.airline.action;

import java.util.List;

import javax.annotation.Resource;

import org.airline.common.IModuleName;
import org.airline.entity.FlightArrange;
import org.airline.entity.Message;
import org.airline.entity.Notice;
import org.airline.entity.User;
import org.airline.service.FlightArrangeService;
import org.airline.service.MessageService;
import org.airline.service.NoticeService;
import org.apache.struts2.ServletActionContext;
import org.springframework.stereotype.Component;

@Component("PrepareDataAction")
@SuppressWarnings("all")
public class PrepareDataAction extends SuperAction {

	private String forwardURL;
	private IModuleName iModuleName;
	private List<Notice> noticeList;
	private NoticeService noticeService;
	private List<Message> messageList;
	private MessageService messageService;
	private List<FlightArrange> flightArrangeList;
	private FlightArrangeService flightArrangeService;
	
	// 首页数据准备
	public String prepareDataForHome() throws Exception {
		try {
			User user = (User) ServletActionContext.getRequest().getSession().getAttribute("Logined");
			System.out.println(user);
			noticeList = noticeService.getNoticeByDate();
			messageList = messageService.getMessageByDate();
			flightArrangeList = flightArrangeService.getFlightArrangeByDate();
		} catch (Exception e) {
			logFailureString(iModuleName.GET, iModuleName.GET, "首页数据准备失败", e);
			e.printStackTrace();
		}
		logSuccessString(iModuleName.GET, iModuleName.GET, "首页数据准备成功");
		forwardURL = "/jsp/index.jsp";
		return SUCCESS;
	}

	public String getForwardURL() {
		return forwardURL;
	}
	public void setForwardURL(String forwardURL) {
		this.forwardURL = forwardURL;
	}
	public IModuleName getiModuleName() {
		return iModuleName;
	}
	public void setiModuleName(IModuleName iModuleName) {
		this.iModuleName = iModuleName;
	}
	public List<Notice> getNoticeList() {
		return noticeList;
	}
	public void setNoticeList(List<Notice> noticeList) {
		this.noticeList = noticeList;
	}
	public NoticeService getNoticeService() {
		return noticeService;
	}
	
	@Resource(name = "NoticeService")
	public void setNoticeService(NoticeService noticeService) {
		this.noticeService = noticeService;
	}
	public List<Message> getMessageList() {
		return messageList;
	}
	public void setMessageList(List<Message> messageList) {
		this.messageList = messageList;
	}
	public MessageService getMessageService() {
		return messageService;
	}
	
	@Resource(name = "MessageService")
	public void setMessageService(MessageService messageService) {
		this.messageService = messageService;
	}
	public List<FlightArrange> getFlightArrangeList() {
		return flightArrangeList;
	}
	public void setFlightArrangeList(List<FlightArrange> flightArrangeList) {
		this.flightArrangeList = flightArrangeList;
	}
	public FlightArrangeService getFlightArrangeService() {
		return flightArrangeService;
	}
	
	@Resource(name = "FlightArrangeService")
	public void setFlightArrangeService(FlightArrangeService flightArrangeService) {
		this.flightArrangeService = flightArrangeService;
	}
	
	
	
	
}
